/**
 * 自己的后台接口开发
 */
const express=require('express');
const bodyParser=require('body-parser');
const router=require('./router.js');
const app=express();

//启动静态资源服务
app.use('/',express.static("public"));
//解决跨域问题
app.all('*',function (req, res, next) {
    res.header('Access-Control-Allow-Origin', '*');
    res.header('Access-Control-Allow-Headers', 'Content-Type, Content-Length, Authorization, Accept, X-Requested-With , yourHeaderFeild');
    res.header('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, OPTIONS');
    res.header("X-Powered-By", ' 3.2.1');
    res.header("Content-Type","application/json;chartset=utf-8");
  　next();　
  });
  //解决post的json格式的文件
  app.use(bodyParser.urlencoded({ extended: false }));
  //路由跳转
  app.use(router);
  app.get('/', function (req, res) {
    res.send("Hello World,this is Node interface of staff information management system in Wang Rui's graduation project");
  })
  //监听3000端口
  app.listen(5050,()=>{
      console.log('running.....');
  })
//   app.listen(3000,()=>{
//       console.log('running....');
//   });